import 'package:appflutterhomeschool/api/api_service.dart';
import 'package:appflutterhomeschool/api/dio_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import '../my_app_view_model.dart';

class AcademicSentimentViewModel extends ChangeNotifier {
  MyAppViewModel myAppViewModel;
  BuildContext me;
  List chengji = [];
  bool identity;

  Map<String, dynamic> nodesMap;

  AcademicSentimentViewModel(this.me);

  Map<String, dynamic> scoresMap;

  initView() {
    myAppViewModel = Provider.of<MyAppViewModel>(me);
    if (myAppViewModel.studentInformationModel == null) {
      return;
    }
    Map<String, dynamic> map = myAppViewModel.identity
        ? {
            "cls_mapping_id":
                myAppViewModel.studentInformationModel.classMappingId,
          }
        : {
            "cls_id": myAppViewModel.studentInformationModel.classId,
            "student_id": myAppViewModel.studentInformationModel.subjectId,
          };
    scoresMap = {
      "score": [83, 85, 82, 87, 91, 85, 88, 90],
      "time": [
        "2020-03-12",
        "2020-04-01",
        "2020-04-22",
        "2020-05-14",
        "2020-05-30",
        "2020-06-23",
        "2020-07-10",
        "2020-08-13"
      ],
      "subject": "成绩曲线"
    };
//    DioUtils.getInstance().post(
//        myAppViewModel.identity
//            ? ApiService.getClsScores
//            : ApiService.getStudentScores,
//        map, (successCallBack) {
//      if (successCallBack == null || successCallBack["data"] == null) {
//        return;
//      }
//      Map<String, dynamic> data = successCallBack["data"];
//      scoresMap =
//          myAppViewModel.identity ? data["cls_scores"] : data["scores"][0];
//      notifyListeners();
//    }, (errorCallBack) {});

//    DioUtils.getInstance().post(
//        myAppViewModel.identity
//            ? ApiService.getClsNodes
//            : ApiService.getStuNodes,
//        {
//          "student_id": myAppViewModel.studentInformationModel.subjectId,
//          "cls_id": myAppViewModel.studentInformationModel.classId,
//        }, (successCallBack) {
//      if (successCallBack == null || successCallBack["data"] == null) {
//        return;
//      }
//      notifyListeners();
//    }, (errorCallBack) {});
  }

  //获取身份
  getIdentityApplication() async {
    this.identity = myAppViewModel.identity;
    initView();
  }
}
